Next | Prev | Up | Top | Contents | Index

Describing the Driver in /var/sysgen/master.d

You describe your driver in a file with the name of the driver in /var/sysgen/master.d. The format of these files is described in two places: the master(4) reference page, and in /var/sysgen/master.d/README. In addition, you can examine the many examples in the distributed system.


Descriptive Line

The first noncomment line of the master file contains a series of fields, delimited by white space, to describe the driver. These fields are:

FlagsDescribed in the text.
PrefixThe string of 1-14 characters that identify the public symbols of driver entry points.
Major numberThe major number, or a comma-separated list of major numbers, found in device special files that are managed by this driver.
Number of sub-devicesSize of the driver's static arrays of device information, or given as a hyphen "-" when not known.
DependenciesA list of other modules that must be in the kernel for this driver to work--usually omitted except for SCSI drivers.

Of the many flags that can be specified in the first field, the following are most frequently used:

b or c Block (b) or character (c) device. One or the other is essential for any device driver.
f or m STREAMS driver (f) or module (m).
n or pMultiprocessor-aware (n) or uniprocessor-only (p) driver. This flag must correspond to the presence or absence of D_MP in the pfxdevflag global.
s Software driver, either a pseudo-device or a SCSI driver.

The s (software-only) flag tells lboot not to attempt to probe for hardware. This is the case with software-only (pseudo-device) drivers, and with SCSI drivers. If lboot tries to probe for a SCSI device, it fails, and assumes that the device is not present, and does not include your SCSI device driver.

Additional flags (d, R, N, D) for loadable drivers are discussed later under "Configuring a Loadable Driver".


Listing Dependencies

The descriptive line ends with a comma-separated list of other loadable kernel modules on which this driver depends. The lboot command makes sure that, if it fails to load a dependent module, it also will not load this module.

In most cases, an OEM driver does not have any dependencies. However, a SCSI driver (see Chapter 15, "SCSI Device Drivers") should list the name scsi, since it depends on the inner SCSI driver. A STREAMS driver might list the name of a STREAMS support module such as clone (see "Support for CLONE Drivers").

It is possible for you to design a driver in the form of multiple, loadable modules. In that case, you would name your support modules in this field.


Stubs Section

Noncomment lines that follow the descriptive line and precede a line beginning "$" are used by library modules--not by device drivers or STREAMS drivers. Each such line specifies an entry point that this module provides, and which is used by the kernel or some other loadable module. These lines instruct lboot in how to create a harmless "stub" function in the event that this driver is not included in the kernel--for example, because it is specified by an EXCLUDE line in the system file. The format is discussed in the master(4) reference page.

Since a device or STREAMS driver provides only standard entry points that are accessed via the switch tables rather than by linking, drivers do not need to define any stubs.


Variables Section

Following the descriptive line (and the stubs section, if any), you can place a line that begins with "$" and, following this, you can write definitions of global variables using C syntax. This text is compiled into a module linked with the kernel. You refer to these variables as extern in the driver source code.

The advantage of defining global variables in the master file is that the initializing expressions for these variables can include the major device number and the number of supported sub-devices, as specified in the descriptive line of the file. This is how you make these items available to your driver without coding them into the driver. In the source code of the driver you can write

extern major_t myMajNum;
extern int myDevLimit;
In the master file you can write

$$$
major_t myMajNum = ##E;
int myDevLimit = ##C;
The global myDevLimit is compiled with the number of devices from the descriptive line. The global myMajNum is compiled with the major number. (In a loadable driver this technique requires one additional step; see "Master File for Loadable Drivers".)


Next | Prev | Up | Top | Contents | Index